//
//  calenderDetailTableViewCell.m
//  New
//
//  Created by dlios on 15-7-21.
//  Copyright (c) 2015年 yangTao. All rights reserved.
//

#import "calenderDetailTableViewCell.h"

@implementation calenderDetailTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatSubView];
        
    }
    return self;
}

-(void)creatSubView{
    if (WIDTH > 375) {
        self.imagV = [[UIImageView alloc]initWithFrame:CGRectMake(20, 10, self.frame.size.width+50 , 100)];
        self.imagV.backgroundColor = [UIColor clearColor];
        //    imagV.image = [UIImage imageNamed:@"bg_share_large.png"];
        [self addSubview:self.imagV];
    }if (WIDTH == 375) {
        self.imagV = [[UIImageView alloc]initWithFrame:CGRectMake(20, 10, self.frame.size.width , 100)];
        self.imagV.backgroundColor = [UIColor clearColor];
        //    imagV.image = [UIImage imageNamed:@"bg_share_large.png"];
        [self addSubview:self.imagV];
  
    }else if(WIDTH < 375)
    {
        self.imagV = [[UIImageView alloc]initWithFrame:CGRectMake(20, 10, self.frame.size.width-50 , 100)];
        self.imagV.backgroundColor = [UIColor clearColor];
        //    imagV.image = [UIImage imageNamed:@"bg_share_large.png"];
        [self addSubview:self.imagV];

    
    }
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 70, self.imagV.frame.size.width, 1)];
    view.backgroundColor = [UIColor lightGrayColor];
    [self.imagV addSubview:view];
    
    UIView *view2 = [[UIView alloc]initWithFrame:CGRectMake(0, 100, self.imagV.frame.size.width, 1)];
    view2.backgroundColor = [UIColor lightGrayColor];
    [self.imagV addSubview:view2];
    
    
    UIView *view3 = [[UIView alloc]initWithFrame:CGRectMake(0, 10, 1, 90)];
    view3.backgroundColor = [UIColor lightGrayColor];
    [self.imagV addSubview:view3];
    UIView *view4 = [[UIView alloc]initWithFrame:CGRectMake(self.imagV.frame.size.width, 10,1, 90)];
    view4.backgroundColor = [UIColor lightGrayColor];
    [self.imagV addSubview:view4];
    
    self.countryImge = [[UIImageView alloc]initWithFrame:CGRectMake(2, 0, self.imagV.frame.size.width/4, 65)];
    self.countryImge.backgroundColor =[UIColor clearColor];
    [self.imagV addSubview:self.countryImge];
    
    self.title = [[BaseLabel alloc]initWithFrame:CGRectMake(self.imagV.frame.size.width/4 +2, 0, self.imagV.frame.size.width/2, 65)];
    self.title.backgroundColor = [UIColor clearColor];
    self.title.numberOfLines = 0;
    [self.imagV addSubview:self.title];
    
     if (self.frame.size.width >= 375) {
    self.time = [[BaseLabel alloc]initWithFrame:CGRectMake(self.imagV.frame.size.width/4 *3 + 2, self.title.frame.size.height/3, self.imagV.frame.size.width/4 -5, self.title.frame.size.height/2)];
    self.time.backgroundColor =[UIColor lightGrayColor];
    self.time.font = [UIFont systemFontOfSize:13];
    [self.imagV addSubview:self.time];
     }else{
         self.time = [[BaseLabel alloc]initWithFrame:CGRectMake(self.imagV.frame.size.width/4 *3 + 2, self.title.frame.size.height/3, self.imagV.frame.size.width/4 -5, self.title.frame.size.height/2)];
         self.time.backgroundColor =[UIColor lightGrayColor];
         self.time.font = [UIFont systemFontOfSize:10];
         [self.imagV addSubview:self.time];
     }

    self.label1 = [[BaseLabel alloc]initWithFrame:CGRectMake(0, 72, self.imagV.frame.size.width/3, 25)];
    self.label1.backgroundColor =[UIColor clearColor];
    [self.imagV addSubview:self.label1];
    
    self.label2 = [[BaseLabel alloc]initWithFrame:CGRectMake(self.imagV.frame.size.width/3, 72, self.imagV.frame.size.width/3, 25)];
    self.label2.backgroundColor =[UIColor clearColor];
    [self.imagV addSubview:self.label2];
    
    self.label3 = [[BaseLabel alloc]initWithFrame:CGRectMake(self.imagV.frame.size.width/3*2, 72, self.imagV.frame.size.width/3, 25)];
    self.label3.backgroundColor =[UIColor clearColor];
    [self.imagV addSubview:self.label3];
    
}

-(void)setCalenMod:(CalenderModel *)calenMod{

    if (_calenMod != calenMod) {
        _calenMod = calenMod;
    }

    
    self.title.text = [NSString stringWithFormat:@"(%@)%@",calenMod.country,calenMod.title];
    NSString *string = [calenMod.currency substringToIndex:2];
    NSString *path = [NSString stringWithFormat:@"%@.png",string];
    self.countryImge.image = [UIImage imageNamed:path];
    
   
    
    self.time.text = [NSString stringWithFormat:@"%@已公布",[[calenMod.localDateTime substringFromIndex:11] substringToIndex:5]];

    NSString *str  = [NSString stringWithFormat:@"%@",calenMod.actual];
 
    if ((str.length == 5)||(str.length == 4)) {
       
         self.label1.text = [NSString stringWithFormat:@"今值 %@",calenMod.actual];
    }else{
    
        self.label1.text = @"今值 --";
    }
    NSString *str1 = [NSString stringWithFormat:@"%@",calenMod.forecast];
    if ((str1.length == 5)||(str1.length == 4)) {
        
        self.label2.text = [NSString stringWithFormat:@"预期 %@",calenMod.forecast];
    }else{
        
        self.label2.text = @"预期 --";
    }


    NSString *str3 = [NSString stringWithFormat:@"%@",calenMod.previous];
    if ((str3.length == 5)||(str3.length == 4)) {
        
        self.label3.text = [NSString stringWithFormat:@"前值 %@",calenMod.previous];
    }else{
        
        self.label3.text = @"前值 --";
    }

    
}




@end
